﻿using Common;
using MaterialDesignThemes.Wpf;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using Sigma.Admin.Client.DialogAware;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sigma.Admin.Client.ViewModels
{
    public class ShowTipsViewModel : BindableBase, IDialogHostAware
    {
        public ShowTipsViewModel()
        {
            SaveCommand = new DelegateCommand(Save);
            CancelCommand = new DelegateCommand(Cancel);
        }

        private TipsModel _tipsModel;

        public TipsModel TipsModel
        {
            get { return _tipsModel; }
            set { _tipsModel = value; RaisePropertyChanged(); }
        }
        private void Cancel()
        {
            if (DialogHost.IsDialogOpen(DialogHostName))
                DialogHost.Close(DialogHostName, new DialogResult(ButtonResult.No));
        }

        private void Save()
        {
            //tips没有save功能
        }

        public string DialogHostName { get; set; }
        public DelegateCommand SaveCommand { get; set; }
        public DelegateCommand CancelCommand { get; set; }

        //接收参数并绑定模型
        public void OnDialogOpend(IDialogParameters parameters)
        {
            if (parameters.ContainsKey("Tips"))
            {
                TipsModel = parameters.GetValue<TipsModel>("Tips");
            }
            else
                TipsModel = new TipsModel() { Title = "无消息 Null-Exception" };
            
        }
    }

    public class TipsModel
    {
        public string Title { get; set; }

        public List<string> Tips { get; set; }
    }
}
